﻿<!DOCTYPE HTML>
<html>
{include file="public:header_css"}
<link rel="Bookmark" href="/favicon.ico" >
<link rel="Shortcut Icon" href="/favicon.ico" />
<!--[if lt IE 9]>
<script type="text/javascript" src="__STATIC__/admin/lib/html5shiv.js"></script>
<script type="text/javascript" src="__STATIC__/admin/lib/respond.min.js"></script>
<![endif]-->
<link rel="stylesheet" type="text/css" href="__STATIC__/admin/static/h-ui/css/H-ui.min.css" />
<link rel="stylesheet" type="text/css" href="__STATIC__/admin/static/h-ui.admin/css/H-ui.admin.css" />
<link rel="stylesheet" type="text/css" href="__STATIC__/admin/lib/Hui-iconfont/1.0.8/iconfont.css" />
<link rel="stylesheet" type="text/css" href="__STATIC__/admin/static/h-ui.admin/skin/default/skin.css" id="skin" />
<link rel="stylesheet" type="text/css" href="__STATIC__/admin/static/h-ui.admin/css/style.css" />
<!--[if IE 6]>
<script type="text/javascript" src="__STATIC__/admin/lib/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
<!--/meta 作为公共模版分离出去-->

<link href="__STATIC__/admin/lib/webuploader/0.1.5/webuploader.css" rel="stylesheet" type="text/css" />

<!--<link rel="stylesheet" type="text/css" href="__STATIC__/webupload/css/webuploader.css"/>-->
<body>

<nav class="breadcrumb">
	<i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 广告管理 <span class="c-gray en">&gt;</span> 添加广告
	<a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a>
</nav>

<div class="page-container">

	<form action="" method="post" class="form form-horizontal" id="form-shops-add" enctype="multipart/form-data" name="myForm">
		<!--标题内容-->
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>标题：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" class="input-text" value="" placeholder="" id="title" name="title" style="width:60%;">
			</div>
		</div>
		<!--报名费用-->
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>报名费用：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="number" class="input-text" placeholder="" name="free" id="free" style="width:60%;">
			</div>
		</div>
		<!--活动时间-->
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>活动时间：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" class="input-text Wdate" id="start_time" name="start_time" value="" onfocus="WdatePicker({ dateFmt:'yyyy-MM-dd' })" style="width:24%;"> -
				<input type="text" class="input-text Wdate" id="end_time" name="end_time" value="" onfocus="WdatePicker({ dateFmt:'yyyy-MM-dd' })" style="width:24%;">
			</div>
		</div>
		<!--是否发红包-->
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>是否发红包：</label>

				<div class="radio-box">
					<input type="radio" id="radio-1"  value="1" onclick="t(1)" name="radio1">
					<label for="radio-1">是</label>
				</div>
				<div class="radio-box">
					<input type="radio" id="radio-2"  value="0" onclick="t(2)" name="radio1" checked="checked">
					<label for="radio-2">否</label>
				</div>

		</div>

		<!--最大金额  最小金额-->
		<div class="row cl"  id="mx" style="display: none">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>最大金额：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" class="input-text" placeholder="" name="max" id="max" style="width:60%;">
			</div>
		</div>

		<div class="row cl"  id="mi" style="display: none">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>最小金额：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" class="input-text" placeholder="" name="min" id="min" style="width:60%;">
			</div>
		</div>

		<!--选择音乐-->
		<div class="row cl" >
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>选择音乐：</label>
			<div class="formControls col-xs-8 col-sm-9"  style="width: 46%">
			<table class="table table-border table-bordered table-bg table-hover table-sort">
				<thead>
				<tr class="text-c">

					<th width="50">ID</th>
					<th width="50">音乐名称</th>
					<th width="50">操作</th>
				</tr>
				</thead>
				<tbody>
				{foreach name="list" item="v" key="k"}
				<tr class="text-c">
					<td>{$v.id}</td>
					<td class="text-c">{$v.title}</td>
					<td class="td-status">
						<div class="check-box">
							{if $v.id == $mid}
							<input type="radio" id="radio" value="{$v.id}" name="demo-radio"  checked="checked">
							{else}
							<input type="radio" id="radio" value="{$v.id}" name="demo-radio">
							{/if}
							<!--<input type="radio" id="radio" value="{$v.id}" name="demo-radio" >-->
							<label for="radio-1">选择</label>
						</div>
					</td>
				</tr>
				{/foreach}
				</tbody>
			</table>
			</div>
		</div>

		<!--选择皮肤-->
		<div class="row cl" >
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>选择皮肤：</label>
			<div class="formControls col-xs-8 col-sm-9"  style="width: 46%">
				<table class="table table-border table-bordered table-bg table-hover table-sort">
					<thead>
					<tr class="text-c">

						<th width="50">ID</th>
						<th width="50">皮肤名称</th>
						<th width="50">操作</th>
					</tr>
					</thead>
					<tbody>
					{foreach name="list1" item="v" key="k"}
					<tr class="text-c">
						<td>{$v.id}</td>
						<td class="text-c">{$v.title}</td>
						<td class="td-status">
							<div class="check-box">
								{if $v.id == $sid}
								<input type="radio"  id="radio1" value="{$v.id}" name="demo-radio1" checked="checked">
								{else}
								<input type="radio" id="radio1"  value="{$v.id}" name="demo-radio1" >
								{/if}
								<!--<input type="radio" id="radio1"  value="{$v.id}" name="demo-radio1" >-->
								<label for="radio-1">选择</label>
							</div>
						</td>
					</tr>
					{/foreach}
					</tbody>
				</table>
			</div>
		</div>

		<!--添加轮播图-->
		<div class="row cl" >
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>添加轮播图：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<div style="float: left">
					<div  id="checkshow1" style="width:150px;height: 150px;padding: 5px;border: 1px solid #e6e6e6;border-radius: 10px;">
						<img src="" alt=""  id="ImgPreview1" style="width: 100%;height: 100%"/>
					</div>
					<div style="margin: 10px 0 0 10px;float: left;width: 254px">
						<div  id= "up_img1">图片1</div>
						<span style="color:#c8a0a0;">建议上传图片尺寸720*960</span>
					</div>

				</div>

				<div  style="float: left">
					<div  id="checkshow2" style="width:150px;height: 150px;padding: 5px;border: 1px solid #e6e6e6;border-radius: 10px;">
						<img src="" alt=""  id="ImgPreview2" style="width: 100%;height: 100%"/>
					</div>
					<div style="margin: 10px 0 0 10px;float: left;width: 254px">
						<div  id= "up_img2">图片2</div>
						<span style="color:#c8a0a0;">建议上传图片尺寸720*960</span>
					</div>
				</div>
			</div>
		</div>
		<div class="row cl" >
			<label class="form-label col-xs-4 col-sm-3"></label>
			<div class="formControls col-xs-8 col-sm-9">
				<div style="float: left">
					<div  id="checkshow3" style="width:150px;height: 150px;padding: 5px;border: 1px solid #e6e6e6;border-radius: 10px;">
						<img src="" alt=""  id="ImgPreview3" style="width: 100%;height: 100%"/>
					</div>
					<div style="margin: 10px 0 0 10px;float: left;width: 254px">
						<div  id= "up_img3">图片3</div>
						<span style="color:#c8a0a0;">建议上传图片尺寸720*960</span>
					</div>

				</div>

				<div  style="float: left">
					<div  id="checkshow4" style="width:150px;height: 150px;padding: 5px;border: 1px solid #e6e6e6;border-radius: 10px;">
						<img src="" alt=""  id="ImgPreview4" style="width: 100%;height: 100%"/>
					</div>
					<div style="margin: 10px 0 0 10px;float: left;width: 254px">
						<div  id= "up_img4">图片4</div>
						<span style="color:#c8a0a0;">建议上传图片尺寸720*960</span>
					</div>
				</div>
			</div>
		</div>


		<!--HandyEditor   副文本编辑器开始-->
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2">文章内容：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<script id="editor" type="text/plain" style="width:100%;height:400px;"></script>
                </div>
				</div>



		<!--HandyEditor   副文本编辑器结束-->
		<div class="row cl">
			<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
				<a class="btn btn-primary radius" id="submit">&nbsp;&nbsp;提交&nbsp;&nbsp;</a>
                <a class="btn btn-warning radius" href="{:url('index')}">&nbsp;&nbsp;取消&nbsp;&nbsp;</a>
			</div>
		</div>
	</form>

</div>
{include file="public:footer_js"}

<script type="text/javascript" src="__STATIC__/admin/lib/My97DatePicker/4.8/WdatePicker.js"></script>
<script type="text/javascript" src="__STATIC__/admin/lib/jquery.validation/1.14.0/jquery.validate.js"></script>
<script type="text/javascript" src="__STATIC__/admin/lib/jquery.validation/1.14.0/validate-methods.js"></script>
<script type="text/javascript" src="__STATIC__/admin/lib/jquery.validation/1.14.0/messages_zh.js"></script>

<script type="text/javascript" src="__STATIC__/admin/lib/webuploader/0.1.5/webuploader.min.js"></script>
<script type="text/javascript" src="__STATIC__/admin/lib/ueditor/1.4.3/ueditor.config.js"></script>
<script type="text/javascript" src="__STATIC__/admin/lib/ueditor/1.4.3/ueditor.all.min.js"> </script>
<script type="text/javascript" src="__STATIC__/admin/lib/ueditor/1.4.3/lang/zh-cn/zh-cn.js"></script>


<script type="text/javascript" src="__STATIC__/webupload/js/jquery.js"></script>
<script type="text/javascript" src="__STATIC__/webupload/js/webuploader.js"></script>





<!--HandyEditor   副文本编辑器开始-->
<script type="text/javascript">
    var he = HE.getEditor('editor',{
        autoHeight : true,
        autoFloat : false,
        topOffset : 0,
        uploadPhoto : true,
        uploadPhotoHandler : "/php/uploadPhoto.php",
        uploadPhotoSize : 0,
        uploadPhotoType : 'gif,png,jpg,jpeg',
        uploadPhotoSizeError : '不能上传大于××KB的图片',
        uploadPhotoTypeError : '只能上传gif,png,jpg,jpeg格式的图片',
        lang : 'zh-jian',
        skin : 'HandyEditor',
        externalSkin : '',
        item : ['bold','italic','strike','underline','fontSize','fontName','paragraph','color','backColor','|','center','left','right','full','indent','outdent','|','link','unlink','textBlock','code','selectAll','removeFormat','trash','|','image','expression','subscript','superscript','horizontal','orderedList','unorderedList','|','undo','redo','|','html','|','about']
    });
    function getHtml(){
        alert(he.getHtml());
    }
    function getText(){
        alert(he.getText());
    }
</script>

<script type="text/javascript">



    <!--第一张图片 赚字图片开始-->
    // 上传图片
    var uploader = WebUploader.create({
        // swf文件路径
        swf: '__STATIC__/webupload/js/Uploader.swf',

        // 文件接收服务端。
        server: "{:url('admin/qiniu/upload')}",

        // 选择文件的按钮。可选。
        // 内部根据当前运行是创建，可能是input元素，也可能是flash.
        pick: '#up_img1',

        // 限制文件上穿大小为100M
        fileSingleSizeLimit: 100*1024*1024,
        auto:true,

        // 不压缩image, 默认如果是jpeg，文件上传前会压缩一把再上传！
        resize: false,

        // 只允许选择图片文件。
        accept: {
            title: 'Images',
            extensions: 'gif,jpg,jpeg,bmp,png',
            mimeTypes: 'image/*'
        }
    });
    uploader.on("error",function(type){
        if (type == "Q_TYPE_DENIED") {
            alert("请上传图片格式文件");
        } else if (type == "F_EXCEED_SIZE") {
            alert("文件大小不能超过8M");
        } else if (type == "Q_EXCEED_NUM_LIMIT") {
            alert("只能上传一个图片");
        }
    });
    uploader.on('uploadSuccess', function (file, response) {

        if(file.name == null || file.name == 'undefind'){
            alert("上传失败");
            return;
        }else {
            var $img = $("#ImgPreview1");
            $img.attr( 'src', response.url );
        }
    });



    <!--第二张图片 滑动条图片-->
    // 上传图片
    var uploader = WebUploader.create({
        // swf文件路径
        swf: '__STATIC__/webupload/js/Uploader.swf',

        // 文件接收服务端。
        server: "{:url('admin/qiniu/upload')}",

        // 选择文件的按钮。可选。
        // 内部根据当前运行是创建，可能是input元素，也可能是flash.
        pick: '#up_img2',

        // 限制文件上穿大小为100M
        fileSingleSizeLimit: 100*1024*1024,
        auto:true,

        // 不压缩image, 默认如果是jpeg，文件上传前会压缩一把再上传！
        resize: false,

        // 只允许选择图片文件。
        accept: {
            title: 'Images',
            extensions: 'gif,jpg,jpeg,bmp,png',
            mimeTypes: 'image/*'
        }
    });
    /**
     * 验证文件格式、数量以及文件大小
     */
    uploader.on("error",function(type){
        if (type == "Q_TYPE_DENIED") {
            alert("请上传图片格式文件");
        } else if (type == "F_EXCEED_SIZE") {
            alert("文件大小不能超过8M");
        } else if (type == "Q_EXCEED_NUM_LIMIT") {
            alert("只能上传一个图片");
        }
    });
    uploader.on('uploadSuccess', function (file, response) {

        if(file.name == null || file.name == 'undefind'){
            alert("上传失败");
            return;
        }else {
            var $img = $("#ImgPreview2");
            $img.attr( 'src', response.url );
        }
    });

    <!--第三张图片 滑动按钮开始-->
    // 上传图片
    var uploader = WebUploader.create({
        // swf文件路径
        swf: '__STATIC__/webupload/js/Uploader.swf',

        // 文件接收服务端。
        server: "{:url('admin/qiniu/upload')}",

        // 选择文件的按钮。可选。
        // 内部根据当前运行是创建，可能是input元素，也可能是flash.
        pick: '#up_img3',

        // 限制文件上穿大小为100M
        fileSingleSizeLimit: 100*1024*1024,
        auto:true,

        // 不压缩image, 默认如果是jpeg，文件上传前会压缩一把再上传！
        resize: false,

        // 只允许选择图片文件。
        accept: {
            title: 'Images',
            extensions: 'gif,jpg,jpeg,bmp,png',
            mimeTypes: 'image/*'
        }
    });
    // 查出限制提示
    /**
     * 验证文件格式、数量以及文件大小
     */
    uploader.on("error",function(type){
        if (type == "Q_TYPE_DENIED") {
            alert("请上传图片格式文件");
        } else if (type == "F_EXCEED_SIZE") {
            alert("文件大小不能超过8M");
        } else if (type == "Q_EXCEED_NUM_LIMIT") {
            alert("只能上传一个图片");
        }
    });
    uploader.on('uploadSuccess', function (file, response) {

        if(file.name == null || file.name == 'undefind'){
            alert("上传失败");
            return;
        }else {
            var $img = $("#ImgPreview3");
            $img.attr( 'src', response.url );
        }
    });

    <!--第四张图片 背景图片结束-->
    // 上传图片
    var uploader = WebUploader.create({
        // swf文件路径
        swf: '__STATIC__/webupload/js/Uploader.swf',

        // 文件接收服务端。
        server: "{:url('admin/qiniu/upload')}",

        // 选择文件的按钮。可选。
        // 内部根据当前运行是创建，可能是input元素，也可能是flash.
        pick: '#up_img4',

        // 限制文件上穿大小为100M
        fileSingleSizeLimit: 100*1024*1024,
        auto:true,

        // 不压缩image, 默认如果是jpeg，文件上传前会压缩一把再上传！
        resize: false,

        // 只允许选择图片文件。
        accept: {
            title: 'Images',
            extensions: 'gif,jpg,jpeg,bmp,png',
            mimeTypes: 'image/*'
        }
    });
    uploader.on("error",function(type){
        if (type == "Q_TYPE_DENIED") {
            alert("请上传图片格式文件");
        } else if (type == "F_EXCEED_SIZE") {
            alert("文件大小不能超过8M");
        } else if (type == "Q_EXCEED_NUM_LIMIT") {
            alert("只能上传一个图片");
        }
    });
    uploader.on('uploadSuccess', function (file, response) {

        if(file.name == null || file.name == 'undefind'){
            alert("上传失败");
            return;
        }else {
            var $img = $("#ImgPreview4");
            $img.attr( 'src', response.url );
        }
    });




</script>
<script type="text/javascript">

		function t(a) {
			if(a == 1){
			$("#mx").show();
			$("#mi").show();
			}
			if(a == 2){
                $("#mx").hide();
                $("#mi").hide();
			}

		}
        var ue = UE.getEditor('editor');
        // 提交数据
		$("#submit").click(function () {
			console.log(ue.getContent());

            var title 		= $("#title").val();
            var pay_money 		= $("#free").val();
            var start_time	= $("#start_time").val();
            var end_time 	= $("#end_time").val();

            var is_red_packet = $("input[name='radio1']:checked").val();
            var red_max 	= $("#max").val();
            var red_min 	= $("#min").val();
            var music_id = $("input[name='demo-radio']:checked").val();
            var skin_id = $("input[name='demo-radio1']:checked").val();

            var banner1_url		= $("#ImgPreview1").attr("src");
            var banner2_url		= $("#ImgPreview2").attr("src");
            var banner3_url		= $("#ImgPreview3").attr("src");
            var banner4_url		= $("#ImgPreview4").attr("src");

            var text            = ue.getContent();
            if($("input[name='radio1']:checked").val() == '' || $("input[name='radio1']:checked").val() == "undefined"){
                layer.msg("请选择是否发红包",{icon:5,time:1000});
                $("#is_red_packet").focus();
                return;
            }
            // 标题不可为空
            if(title === '' || title === "undefined"){
                layer.msg("请填写标题",{icon:5,time:1000});
                $("#title").focus();
                return;
			}
            if(pay_money === '' || pay_money === "undefined"){
                layer.msg("请填写报名费用",{icon:5,time:1000});
                $("#free").focus();
                return;
            }
            // start_time不可为空
            if(start_time === '' || start_time === "undefined"){
                layer.msg("开始时间不可为空",{icon:5,time:1000});
                $("#start_time").focus();
                return;
            }

            // end_time不可为空
            if(end_time === '' || end_time === "undefined"){
                layer.msg("结束时间不可为空",{icon:5,time:1000});
                $("#end_time").focus();
                return;
            }

            // 异步提交数据
            $.post(
                "{:url('paymanager')}",
                {
                    title:title,
                    pay_money:pay_money,
                    start_time:start_time,
                    end_time:end_time,
                    is_red_packet:is_red_packet,
                    red_max:red_max,
                    red_min:red_min,
                    music_id:music_id,
                    skin_id:skin_id,
                    banner1_url:banner1_url,
                    banner2_url:banner2_url,
                    banner3_url:banner3_url,
                    banner4_url:banner4_url,
					text:text
                },
                function (res) {

                    if(res.code === 0){

                        layer.msg(res.msg,{icon:5,time:2000});

                    }else{

                        layer.msg(res.msg,{icon:6,time:2000});

                        // 定时跳转页面
                        setTimeout(
                            // 跳转至管理后台首页
                            function(){
                            location.replace("{:url('index')}");
                            },
                            3000
                        );
                    }
                }
            );

        });


</script>

</body>
</html>